package NGUYENLAMSON.ARRAY;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Baitoan1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//Khai bao va khoi tao bien mang dong 1D
		List<String>lisString=new ArrayList<String>();// Bieu dien List thong qua ArrayList
		List<String>lisString01=new ArrayList<String>();
		List<Double>lisDouble = new ArrayList<Double>();
		List<Integer>lisInterger = new ArrayList<Integer>();
		// 2 Dua gia tri vao mang 
		lisString.add("Nguyen Van A");
		lisString.add("Nguyen Van B");
		lisString.add("Nguyen Van C");
		lisString.add("Nguyen Van D");		
		//3 Hien gia tri trong mang 
		
		for(int i=0;i<lisString.size();i++){
			System.out.println("+gia tri :+"+lisString.get(i));
		}
		// 4 Lenh xoa du lieu 
	//lisString.clear();
	//5 Lenh copy du lieu tu List nay sang List khac 
		lisString01.addAll(lisString);
		for(int i=0;i<lisString01.size();i++){
			System.out.println("+gia tri :"+lisString01.get(i));
		}
		//6 Lenh kiem tra gia tri co trong List hay khong 
		if(lisString.contains("Nguyen Van E")){
			System.out.println("Co ten nay :");
		}else 
			System.out.println("khong co ten nay:");
		//7 Thiet lap gia tri cho cac chi so phan tu tuong ung 
		lisString.set(2, "Nguyen Van E");
		for(int i=0;i<lisString.size();i++){
			System.out.println("+gia tri :+"+lisString.get(i));
		}
		//8 Xoa mot gia tri nao do trong List dua vao chi so  phan tu 
		lisString.remove(3);
		for(int i=0;i<lisString.size();i++){
			System.out.println("+gia tri :+"+lisString.get(i));
		}
		//9 Tra ve kich thuoc hien tai cua List
		lisString.size();
		System.out.println("kich thuoc cua mang la :"+lisString.size());
		//10 Sap xep tap gia tri trong mang 
		lisDouble.add(6.2);
		lisDouble.add(5.3);
		lisDouble.add(8.0);
		lisDouble.add(10.0);
	Collections.sort(lisDouble);
	for(int i=0;i<lisDouble.size();i++){
		System.out.println("+gia tri :+"+lisDouble.get(i));
	}
	//11 Nhan ve vi tri dang chua gia tri hien thoi 
int Index =lisString.indexOf("Nguyen Van A");
System.out.println("Vi tri :"+Index);
//12 Kiem tra mang co rong hay khong
if (lisString.isEmpty()){
	System.out.println("mang rong :");
}else 
	System.out.println("mang co gia tri");
	}

}
